package com.my.house.service;

import cn.hutool.core.collection.CollUtil;
import com.my.house.domain.FeeRecord;
import lombok.extern.slf4j.Slf4j;
import lombok.RequiredArgsConstructor;
import com.my.house.mapper.FeeRecordMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 水电费房租收费记录表 服务实现类
 * </p>
 *
 * @author yangll
 * @since 2025-02-08
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class FeeRecordService extends ServiceImpl<FeeRecordMapper, FeeRecord> {

    public List<FeeRecord> findByRoomIds(List<Long> roomIds, LocalDate startDate, LocalDate endDate) {
        log.info("findByRoomIds方法参数 roomIds:{},startDate:{},endDate:{}", roomIds, startDate, endDate);
        if (CollUtil.isEmpty(roomIds)) {
            return CollUtil.newArrayList();
        }
        return lambdaQuery().in(FeeRecord::getRoomId, roomIds).between(FeeRecord::getRecDate, startDate, endDate).eq(FeeRecord::getDeleted, Boolean.FALSE).list();
    }
}
